<template>
	<div class="view">
		<web-view :src="path"></web-view>
	</div>
</template>

<script>
	import {
		addBrowserHistory
	} from '@/apis/request.js'

	export default {
		data() {
			return {
				path: ''
			}
		},
		onLoad(options) {
			this.path = decodeURIComponent(options.path)
			if (uni.getStorageSync('token') && this.path.includes('/detail?id')) {
				let id = this.getUrlParam(this.path, 'id')
				this.addRecord(id)
			}
		},
		methods: {
			getUrlParam: function(path, name) {
				var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i")
				if (reg.test(path))
					return unescape(RegExp.$2.replace(/\+/g, " "))
				return ""
			},
			addRecord(id) {
				addBrowserHistory({
					type: 2,
					objectId: id
				}).then(res => {})
			}
		}
	}
</script>

<style scoped lang="scss">
</style>